﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;

namespace FYPHP
{
    public partial class ReferencePrinting : System.Web.UI.Page
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["fyphp"].ConnectionString);

        protected void Page_Load(object sender, EventArgs e)
        {
            lblDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
            lblRef.Text = "REF-" + String.Format("{0:00000}", 1);
            lblUsername.Text = "Ping";
            lblTotal.Text = "18677";

            SqlCommand cmdSelect;
            SqlDataReader dtrSelect;
            conn.Open();

            cmdSelect = new SqlCommand("SELECT * FROM Products p, Transactions t, Transactions_Products tp, Users u WHERE p.p_id=tp.p_id AND t.t_id=tp.t_id AND u.u_id=t.u_id", conn);
            dtrSelect = cmdSelect.ExecuteReader();

            Repeater1.DataSource = dtrSelect;
            Repeater1.DataBind();

            dtrSelect.Close();
            conn.Close();
        }

        public double processData(object quantity, object price)
        {
            double total = int.Parse(quantity.ToString()) * double.Parse(price.ToString());
            return total;
        }
    }
}